# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=bloodyad
pkgver=278.ad667db
pkgrel=2
pkgdesc='An Active Directory Privilege Escalation Framework.'
arch=('any')
groups=('blackarch' 'blackarch-exploitation' 'blackarch-windows')
url='https://github.com/CravateRouge/bloodyAD'
license=('GPL3')
depends=('python' 'python-ldap3' 'python-dsinternals' 'python-winacl' 'impacket'
         'python-neo4j-driver' 'python-gssapi' 'python-msldap'
         'python-dnspython' 'python-minikerberos' 'python-asn1crypto'
         'python-cryptography')
makedepends=('git')
source=("git+https://github.com/CravateRouge/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin/"
  install -Dm 644 requirements.txt "$pkgdir/usr/share/$pkgname/requirements.txt"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" *.md

  rm -rf LICENSE *.md .gitignore

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec python /usr/share/$pkgname/bloodyAD.py "\$@"
EOF

  chmod a+x "$pkgdir/usr/bin/$pkgname"

  cat > "$pkgdir/usr/bin/autobloody" << EOF
#!/bin/sh
exec python /usr/share/$pkgname/autobloody.py "\$@"
EOF

  chmod a+x "$pkgdir/usr/bin/autobloody"

  cat > "$pkgdir/usr/bin/pathgen" << EOF
#!/bin/sh
exec python /usr/share/$pkgname/pathgen.py "\$@"
EOF

  chmod a+x "$pkgdir/usr/bin/pathgen"
}

